/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package session;

import entity.Account;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Admin
 */
@Stateless
public class AccountBean implements AccountBeanRemote, AccountBeanLocal {
    @PersistenceContext(unitName = "AutoAncillariesLimited-ejbPU")
    private EntityManager em;


    public void persist(Object object) {
        em.persist(object);
    }

    public boolean checkLogin(String username, String password) {
        String sql = "select a from Account a where a.username = :username and a.password = :password";
        Query query = em.createQuery(sql);
        query.setParameter("username", username);
        query.setParameter("password", password);

        List result = query.getResultList();

        if (result.size() > 0)
            return true;

        return false;
    }

    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

}
